cmake_minimum_required(VERSION 3.0)

project(ppspd)

enable_testing() # for testing
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose) # add check command

SET(CMAKE_BUILD_TYPE "Debug")
#SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -g -Wall")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O3 -Wall")

include_directories(${PROJECT_SOURCE_DIR}/include)

set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)

aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC_DIR_SRCS)

ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRC_DIR_SRCS})
add_library(alianppspd SHARED ${SRC_DIR_SRCS})

set_target_properties(alianppspd PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(alianppspd PROPERTIES CLEAN_DIRECT_OUTPUT 1)

set(LINKED_LIB ${PROJECT_NAME} ntl gmp pthread) # linked library

add_executable(paillier_run ${PROJECT_SOURCE_DIR}/test/test_paillier.cpp)
target_link_libraries(paillier_run ${LINKED_LIB})
add_test(paillier ${PROJECT_SOURCE_DIR}/bin/paillier_run)

add_executable(sec_mul_run ${PROJECT_SOURCE_DIR}/test/test_sec_mul.cpp)
target_link_libraries(sec_mul_run ${LINKED_LIB})
add_test(sec_mul ${PROJECT_SOURCE_DIR}/bin/sec_mul_run)

add_executable(sec_sed_run ${PROJECT_SOURCE_DIR}/test/test_sec_sed.cpp)
target_link_libraries(sec_sed_run ${LINKED_LIB})
add_test(sec_sed ${PROJECT_SOURCE_DIR}/bin/sec_sed_run)

add_executable(sec_cmp_run ${PROJECT_SOURCE_DIR}/test/test_sec_cmp.cpp)
target_link_libraries(sec_cmp_run ${LINKED_LIB})
add_test(sec_cmp ${PROJECT_SOURCE_DIR}/bin/sec_cmp_run)

add_executable(sec_set_run ${PROJECT_SOURCE_DIR}/test/test_sec_set.cpp)
target_link_libraries(sec_set_run ${LINKED_LIB})
add_test(sec_set ${PROJECT_SOURCE_DIR}/bin/sec_set_run)

add_executable(sec_suez_run ${PROJECT_SOURCE_DIR}/test/test_sec_suez.cpp)
target_link_libraries(sec_suez_run ${LINKED_LIB})
add_test(sec_suez ${PROJECT_SOURCE_DIR}/bin/sec_suez_run)

#Tools
add_executable(net_client_run ${PROJECT_SOURCE_DIR}/test/test_net_client.cpp)
target_link_libraries(net_client_run ${LINKED_LIB})
add_test(net_client ${PROJECT_SOURCE_DIR}/bin/net_client_run)

add_executable(net_server_run ${PROJECT_SOURCE_DIR}/test/test_net_server.cpp)
target_link_libraries(net_server_run ${LINKED_LIB})
add_test(net_server ${PROJECT_SOURCE_DIR}/bin/net_server_run)

add_executable(timer_run ${PROJECT_SOURCE_DIR}/test/test_timer.cpp)
target_link_libraries(timer_run ${LINKED_LIB})
add_test(timer ${PROJECT_SOURCE_DIR}/bin/timer_run)

install(TARGETS ${PROJECT_NAME}  alianppspd DESTINATION lib)
INSTALL (DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h*")

